{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>代理列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->           
            <div class="row">
                <div class="col-sm-12">   
                <div  class="col-sm-2" style="width: 100px">
                    <div class="input-group" >  
                        <a href="{:url('add_member')}"><button class="btn btn-outline btn-primary" type="button">添加代理</button></a> 
                    </div>
                </div>                                    
                    <form name="admin_list_sea" class="form-search" method="post" action="{:url('index')}">
                        <div class="col-sm-3">
                            <div class="input-group">
                                <input type="text" id="key" class="form-control" name="key" value="{$val}" placeholder="输入需查询的代理ID/账号/昵称" />   
                                <span class="input-group-btn"> 
                                    <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button> 
                                </span>
                            </div>
                        </div>
                    </form>
				<div  class="col-sm-4" style="width: 100px">
                    <div class="input-group" >
                        <a href="javascript:;"><button class="btn btn-outline btn-primary" type="button" onclick="del_member_txmoney()">清除已提现金额</button></a> 
                        
                       <button class="btn btn-outline btn-primary" type="button" >余额统计：{$money}  元</button>
                    </div>                    </div>
                </div> 
                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>
            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="long-tr">
							
                                <th width="4%">代理ID</th>
                                <th width="9%">账号</th>
                                <th width="9%">昵称</th>
                                <th width="9%">对应总代</th>
                                <th width="5%">余额</th>
                                <th width="5%">已提现金额</th>
								<th width="5%">提现费率</th>
                                <th width="3%">登次</th>
                                <th width="2%">账号状态</th> 
                                <th width="2%">总代状态</th> 
                                <th width="8%">注册时间</th>
                                <th width="8%">最后登陆时间</th>
                                <th width="6%">入口域名</th>
                                <!--<th width="8%">昨日订单笔数</th>-->
                                <!--<th width="6%">昨日金额</th>-->
                                <th width="5%">操作</th>
                            </tr>
                        </thead>
                        <script id="list-template" type="text/html">
                            {{# for(var i=0;i<d.length;i++){  }}
                            <tr class="long-td">
								
                                <td>{{d[i].id}}</td>
                                <td>{{d[i].account}}</td>
                                <td>{{d[i].nickname}}</td>
                                <td>{{d[i].zong_id}}</td>
                                <td>{{d[i].money}}</td>
								<td>{{d[i].txmoney}}</td>       
                                <td>{{d[i].txfeilv}}%</td>
                                <td>{{d[i].login_num}}</td>                                                                
                                 <td>                             
                                    {{# if(d[i].status==1){ }}
                                        <a class="red" href="javascript:;" onclick="member_status({{d[i].id}});">
                                            <div id="zt{{d[i].id}}"><span class="label label-info">开启</span></div>
                                        </a>
                                    {{# }else{ }}
                                        <a class="red" href="javascript:;" onclick="member_status({{d[i].id}});">
                                            <div id="zt{{d[i].id}}"><span class="label label-danger">禁用</span></div>
                                        </a>
                                    {{# } }}                               
                                </td>
                                
                                <td>                             
                                    {{# if(d[i].status_zong==1){ }}
                                        <a class="red" href="javascript:;" onclick="status_zong({{d[i].id}});">
                                            <div id="zta{{d[i].id}}"><span class="label label-info">开启</span></div>
                                        </a>
                                    {{# }else{ }}
                                        <a class="red" href="javascript:;" onclick="status_zong({{d[i].id}});">
                                            <div id="zta{{d[i].id}}"><span class="label label-danger">禁用</span></div>
                                        </a>
                                    {{# } }}                               
                                </td>
                                <td>{{d[i].create_time}}</td> 
                                <td>{{d[i].last_login_time}}</td> 
                                <td>{{d[i].ename_first}}</td>
                                
                                
                                <td>                                  
                                    <a href="javascript:;" onclick="edit_member({{d[i].id}})" class="btn btn-primary btn-outline btn-xs">
                                        <i class="fa fa-paste"></i> 编辑</a>
                                    <a href="javascript:;" onclick="edit_jiefeng({{d[i].id}})" class="btn btn-primary btn-outline btn-xs">
                                        <i class="fa fa-paste"></i>登录解封</a>
                                    <a href="javascript:;" onclick="edit_txpassword({{d[i].id}})" class="btn btn-primary btn-outline btn-xs">
                                        <i class="fa fa-paste"></i> 设置提现密码</a>
                                    <a href="javascript:;" onclick="edit_password({{d[i].id}})" class="btn btn-primary btn-outline btn-xs">
                                        <i class="fa fa-paste"></i> 设置登录密码</a>
                                    <!--<a href="javascript:;" onclick="del_member({{d[i].id}})" class="btn btn-danger btn-outline btn-xs">
                                        <i class="fa fa-trash-o"></i> 删除</a>--!>                                 
                                </td>
                            </tr>
                            {{# } }}
                        </script>
                        <tbody id="list-content"></tbody>
                    </table>
                    <div id="AjaxPage" style=" text-align: right;"></div>
                    <div id="allpage" style=" text-align: right;"></div>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>

<!-- 加载动画 -->
<div class="spiner-example">
    <div class="sk-spinner sk-spinner-three-bounce">
        <div class="sk-bounce1"></div>
        <div class="sk-bounce2"></div>
        <div class="sk-bounce3"></div>
    </div>
</div>

{include file="public/footer" /}

<script type="text/javascript">
   
    //laypage分页
    Ajaxpage();
    function Ajaxpage(curr){
        var key=$('#key').val();
        $.getJSON('{:url("Member/index")}', {page: curr || 1,key:key}, function(data){
            $(".spiner-example").css('display','none'); //数据加载完关闭动画 
            if(data==''){
                $("#list-content").html('<td colspan="20" style="padding-top:10px;padding-bottom:10px;font-size:16px;text-align:center">暂无数据</td>');
            }else{
                var tpl = document.getElementById('list-template').innerHTML;
                laytpl(tpl).render(data, function(html){
                    document.getElementById('list-content').innerHTML = html;
                });
                laypage({
                    cont: $('#AjaxPage'),//容器。值支持id名、原生dom对象，jquery对象,
                    pages:'{$allpage}',//总页数
                    skip: true,//是否开启跳页
                    skin: '#1AB5B7',//分页组件颜色
                    curr: curr || 1,
                    groups: 3,//连续显示分页数
                    jump: function(obj, first){
                        if(!first){
                            Ajaxpage(obj.curr)
                        }
                        $('#allpage').html('第'+ obj.curr +'页，共'+ obj.pages +'页');
                    }
                });
            }
        });
    }

//编辑代理
function edit_member(id){
    location.href = './edit_member/id/'+id+'.html';
}

//删除代理
function del_member(id){
    dashang.confirm(id,'{:url("del_member")}');
}

function edit_txpassword(id){
    layer.prompt({title: '安全密码：', formType: 1}, function(pass, index){
            layer.close(index);
        layer.prompt({title: '重置提现密码：', formType: 2}, function(text, index){
            layer.close(index);
            // layer.msg('演示完毕！您的口令：'+ pass +'<br>您最后写下了：'+text);
            $.ajax({
                url: "{:url('edit_txpassword')}",
                data: {'id':id,'twopassword':pass,'txpassword':text},
                type: "POST",
                dataType: "json",
                success: function(data) {
                    layer.msg(data['msg']);
                }
            });
        });
    });
}

function edit_jiefeng(id){
    layer.prompt({title: '安全密码：', formType: 1}, function(pass, index){
        layer.close(index);
        // layer.msg('演示完毕！您的口令：'+ pass +'<br>您最后写下了：'+text);
        $.ajax({
            url: "{:url('edit_jiefeng')}",
            data: {'id':id,'twopassword':pass},
            type: "POST",
            dataType: "json",
            success: function(data) {
                layer.msg(data['msg']);
            }
        });
    });
}

function edit_password(id){
    layer.prompt({title: '安全密码：', formType: 1}, function(pass, index){
            layer.close(index);
        layer.prompt({title: '重置登录密码：', formType: 2}, function(text, index){
            layer.close(index);
            // layer.msg('演示完毕！您的口令：'+ pass +'<br>您最后写下了：'+text);
            $.ajax({
                url: "{:url('edit_password')}",
                data: {'id':id,'twopassword':pass,'password':text},
                type: "POST",
                dataType: "json",
                success: function(data) {
                    layer.msg(data['msg']);
                }
            });
        });
    });
}

function del_member_txmoney(id){
    dashang.confirm(id,'/dsadmin/member/del_member_txmoney.html');
}

//用户代理
function member_status(id){
    dashang.status(id,'{:url("member_status")}');
}

//用户代理
function kapian_status(id){
    dashang.status(id,'{:url("member_kapian")}');
}

function status_zong(id){
    dashang.status(id,'{:url("status_zong")}');
}

</script>
</body>
</html>